<template>
    <div class="login-box">
        <h1>这是账号密码登录</h1>
        <el-form :model="loginForm" :rules="rules" ref="acountFormRef">
            <el-form-item prop="username">
                <el-input placeholder="请输入账号" type="text" prefix-icon="el-icon-user" v-model="loginForm.username"></el-input>
            </el-form-item>
            <el-form-item prop="password">
                <el-input placeholder="请输入密码" show-password prefix-icon="el-icon-lock" v-model="loginForm.password"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submit">登录</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    name: 'AcountLogin',
    props: {
        loginForm: {
            type: Object,
            required: true
        },
        rules: {
            type: Object,
            required: true
        }
    },
    data() {
        return {

        }
    },
    methods: {
        submit() {
            this.$refs.acountFormRef.validate(value => {
                if(!value) {
                    console.log('cuole')
                    this.$message.error('账号密码输入有误，请检查')
                }else {
                    this.$emit('acountLogin')
                }
            })
        }
    }
    
}
</script>


<style lang="scss" scoped>
.el-button {
    width: 100%;
    margin-bottom: 150px;
}
</style>